#!/bin/bash
# example ./check_submit_job  job@schedd04.ihep.ac.cn condor04.ihep.ac.cn "metric_cvmfs_junofs.sh metric_cvmfs_lhaasofs.sh"

Site_cm=$2
SiteMetricsfile=$3


SiteMetricstar="${Site_cm}_metrics.tar"
#SiteMetricstar="ihepmonzhengw.tar"
cd /usr/lib64/nagios/plugins/SiteJobMon/SiteMetrics
tar -cvf /usr/lib64/nagios/plugins/SiteJobMon/$SiteMetricstar $3 > /dev/null 2>&1 #create site tar file##


cd /usr/lib64/nagios/plugins/SiteJobMon
#echo "/usr/lib64/nagios/plugins/SiteJobMon/submit_job.sh $1 $2 $SiteMetricstar"
XATTR_VALUE=`/usr/lib64/nagios/plugins/SiteJobMon/submit_job.sh $1 $2 $SiteMetricstar "$SiteMetricsfile"`
if [ $? -ne 0 ]; then
        /bin/echo "submit_job.sh $1 $2 $SiteMetricsfile result $XATTR_VALUE"
        exit $CRITICAL
else
        /bin/echo "submit_job.sh $1 $2 $SiteMetricsfile result OK"
        exit 0
fi

